import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
const team = {

  state: {
    teamInfo: {
      teamId:'',
      teamName:'',
      teamCode:'',
      teamSampleName:'',
    }, 
  },

  mutations: { // 设置变化
    ['setTeamInfo'](state, data) {
      state.teamInfo = data;
      localStorage.setItem("teamInfo", JSON.stringify(data));
    },
  },

  actions: {
    setTeamInfo(context, data) {
      context.commit('setTeamInfo', data);
    },
  },

  getters: {
    getTeamInfo: state=>{
      if ( state.teamInfo.teamName == "" ) {
        state.teamInfo = JSON.parse(localStorage.getItem("teamInfo"));
      }
      return state.teamInfo;
    },
  }
}

export default team